/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.model.events;

/**
 * <p>This is a subclass of XREEvent that represents the "onReady" event. It defines some properties specific to this
 * event. Note that values of all custom properties are actually stored in the XREEvent#params map. Additionally this
 * class is a base for other resource-specific XRE event implementations.</p>
 *
 * <p><strong>Thread safety:</strong> This class is mutable and not thread safe.</p>
 *
 * @author saarixx, jmn
 * @version 1.0
 */
@SuppressWarnings("boxing")
public class XREResourceEvent extends XREEvent {

    /**
     * <p>Represents the name of the "on ready" event.</p>
     *
     * <p>This is a string constant used by the user when setting the name of the event.</p>
     */
    public static final String ON_READY_EVENT_NAME = "onReady";

    /**
     * <p>Represents the name used to retrieve the view parameter.</p>
     */
    private static final String VIEW = "view";

    /**
     * <p>Creates new instance of {@link XREResourceEvent} class.</p>
     */
    public XREResourceEvent() {
        // empty constructor
    }

    /**
     * <p>Retrieves the ID of view associated with the resource that generated the event.</p>
     *
     * @return the ID of view associated with the resource that generated the event
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or the params is
     *                               null
     */
    public int getView() {
        return getTypedParam(VIEW, Integer.class);
    }

    /**
     * <p>Sets the ID of view associated with the resource that generated the event.</p>
     *
     * @param view the ID of view associated with the resource that generated the event
     *
     * @throws IllegalStateException if params is null
     */
    public void setView(int view) {
        setParam(VIEW, view);
    }
}

